<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	template="/pages/template/main-layout.xhtml">

	<ui:define name="content">
		<t:saveState value="#{resultBean.result}" />
		<t:saveState value="#{resultBean.resultDetail}" />
		<t:saveState value="#{resultBean.resultDetailList}" />
		<t:saveState value="#{resultBean.resultList}" />
		<h:panelGrid columns="2" cellpadding="5" width="100%"
			columnClasses="width50,width50" id="panelGrid">
			<h:panelGrid width="100%">
				<p:toolbar>
					<p:toolbarGroup align="right">
						<p:commandLink title="#{msgs.button_add}"
							styleClass="ui-icon ui-icon-circle-plus" type="image"
							actionListener="#{resultBean.addResultAction}"
							update=":mainform:resultList,:mainform:resultDetailList,:messages" />
					</p:toolbarGroup>
				</p:toolbar>
				<p:dataTable id="resultList" value="#{resultBean.resultModel}"
					var="r" emptyMessage="" selectionMode="single">
					<p:ajax event="rowEdit" update=":messages"
						listener="#{resultBean.resultEdit}" />
					<p:ajax event="rowSelect" listener="#{resultBean.resultSelect}"
						update=":mainform:resultDetailList" />
					<f:facet name="header">
						<h:outputText value="#{msgs.qtnaire_result_title}" />
					</f:facet>
					<p:column headerText="#{msgs.default_name}">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{r.name}" />
							</f:facet>
							<f:facet name="input">
								<p:inputText value="#{r.name}" label="#{msgs.default_name}"
									style="width:100%" required="true" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column headerText="#{msgs.table_column_operation}">
						<p:rowEditor />

						<p:commandLink oncomplete="confirmDeleteResult.show()"
							styleClass="ui-icon ui-icon-trash" title="#{msgs.button_delete}"
							type="image">
							<f:setPropertyActionListener value="#{r}"
								target="#{resultBean.result}" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</h:panelGrid>
			<h:panelGrid width="100%">
				<p:toolbar>
					<p:toolbarGroup align="right">
						<p:commandLink title="#{msgs.button_add}"
							styleClass="ui-icon ui-icon-circle-plus" type="image"
							actionListener="#{resultBean.addResultDetailAction}"
							update=":mainform:resultDetailList,:messages" />
					</p:toolbarGroup>
				</p:toolbar>
				<p:dataTable id="resultDetailList"
					value="#{resultBean.resultDetailModel}" var="rd" emptyMessage=""
					selectionMode="single">
					<p:ajax event="rowEdit" update=":messages"
						listener="#{resultBean.resultDetailEdit}" />
					<p:ajax event="rowSelect"
						listener="#{resultBean.resultDetailSelect}"
						update=":mainform:resultDetailList" />
					<f:facet name="header">
						<h:outputText value="#{msgs.qtnaire_result_detail_title}" />
					</f:facet>
					<p:column headerText="#{msgs.default_name}">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{rd.name}" />
							</f:facet>
							<f:facet name="input">
								<p:inputText value="#{rd.name}" label="#{msgs.default_name}"
									style="width:100%" required="true" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column headerText="#{msgs.qtnaire_result_detail_score}">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{rd.score}" />
							</f:facet>
							<f:facet name="input">
								<p:inputText value="#{rd.score}" style="width:100%"
									label="#{msgs.qtnaire_result_detail_score}" required="true">
								</p:inputText>
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column headerText="#{msgs.default_sort}">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{rd.sort}" />
							</f:facet>
							<f:facet name="input">
								<p:inputText value="#{rd.sort}" style="width:100%"
									label="#{msgs.default_sort}" required="true" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column headerText="#{msgs.table_column_operation}">
						<p:rowEditor />

						<p:commandLink oncomplete="confirmDeleteResultDetail.show()"
							styleClass="ui-icon ui-icon-trash" title="#{msgs.button_delete}"
							type="image">
							<f:setPropertyActionListener value="#{rd}"
								target="#{resultBean.resultDetail}" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</h:panelGrid>
		</h:panelGrid>
	</ui:define>

	<ui:define name="dialog">
		<h:panelGrid>
			<p:confirmDialog message="#{msgs.info_sure_delete}" width="200"
				showEffect="explode" hideEffect="explode" header="POZOR"
				severity="alert" widgetVar="confirmDeleteResult" modal="true">
				<p:commandButton value="DA"
					update=":mainform:resultList,:mainform:resultDetailList,:messages"
					actionListener="#{resultBean.deleteResultAction}"
					oncomplete="confirmDeleteResult.hide()" />
				<p:commandButton value="NE" onclick="confirmDeleteResult.hide()"
					type="button" />
			</p:confirmDialog>
			<p:confirmDialog message="#{msgs.info_sure_delete}" width="200"
				showEffect="explode" hideEffect="explode" header="POZOR"
				severity="alert" widgetVar="confirmDeleteResultDetail" modal="true">
				<p:commandButton value="DA" update=":mainform:resultDetailList,:messages"
					actionListener="#{resultBean.deleteResultDetailAction}"
					oncomplete="confirmDeleteResultDetail.hide()" />
				<p:commandButton value="NE" onclick="confirmDeleteResultDetail.hide()"
					type="button" />
			</p:confirmDialog>
		</h:panelGrid>
	</ui:define>
</ui:composition>

